package com.jaws.test.report;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lombok.RequiredArgsConstructor;

import org.testng.Reporter;

import com.google.common.collect.Lists;

/**
 * testng日志封装
 * @author maojian
 * @date 2018-07-05 11:01:54
 * @since v1.0.0
 */
@RequiredArgsConstructor
public class JawsTestngLog {

	/**
	 * 空字符串
	 */
	private static final String EMPTY_STR = "";

	/**
	 * 日志信息
	 */
	private String discription = EMPTY_STR;

	/**
	 * 操作类型
	 */
	private final String operation;

	/**
	 * 额外的参数
	 */
	private Map<String, Object> params = new HashMap<String, Object>();

	private List<String> lineContents = Lists.newArrayList();

	public static JawsTestngLog op(String op) {
		return new JawsTestngLog(op);
	}

	public JawsTestngLog descript(String discription) {
		this.discription = discription;
		return this;
	}

	public JawsTestngLog addline(String str) {
		lineContents.add(str);
		return this;
	}
	
	public static void printClassMethod(String operation, String discription){
		Reporter.log("<h2>" + AbstractReporter.MESSAGES.getString(ReportMetadata.JAWS_LOG_CLASSMTHOD) + operation + "</h2>");
		Reporter.log("<h3 style=\"color:green\">" +AbstractReporter.MESSAGES.getString(ReportMetadata.JAWS_LOG_DISCRIPTION) + discription + "</h3>");
	}
	
	public static void println(String content){
		Reporter.log(content + "</br>");
	}
	
//	public void print() {
//		Reporter.log(AbstractReporter.MESSAGES.getString(ReportMetadata.JAWS_LOG_CLASSMTHOD) + this.operation);
//		Reporter.log(AbstractReporter.MESSAGES.getString(ReportMetadata.JAWS_LOG_DISCRIPTION) + this.discription);
//		Reporter.log(AbstractReporter.MESSAGES.getString(ReportMetadata.JAWS_LOG_CONTENT));
//		for (String line : lineContents) {
//			Reporter.log("    " + line);
//		}
//	}

}
